package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.dto.StatusDTO;
import com.htgd.gardenexpo.entity.CommonResult;
import com.htgd.gardenexpo.entity.GeConFreeSportsTask;
import com.htgd.gardenexpo.dao.GeConFreeSportsTaskMapper;
import com.htgd.gardenexpo.service.IGeConFreeSportsTaskService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 自由跑任务 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-04-02
 */
@Service
public class GeConFreeSportsTaskServiceImpl extends ServiceImpl<GeConFreeSportsTaskMapper, GeConFreeSportsTask> implements IGeConFreeSportsTaskService {

    @Autowired
    private GeConFreeSportsTaskMapper geConFreeSportsTaskMapper;

    @Override
    public CommonResult add(String openId) {
        GeConFreeSportsTask geConFreeSportsTask = new GeConFreeSportsTask();
        geConFreeSportsTask.setOpenId(openId);
        geConFreeSportsTask.setStatus("1");
        geConFreeSportsTaskMapper.insert(geConFreeSportsTask);
        return CommonResult.success("添加成功",geConFreeSportsTask.getId());
    }

    @Override
    public CommonResult changeStatus(StatusDTO statusDTO) {
        lambdaUpdate().eq(GeConFreeSportsTask::getId,statusDTO.getId())
                .set(GeConFreeSportsTask::getStatus,statusDTO.getStatus())
                .update();
        return CommonResult.success("修改成功");
    }
}
